package cn.xopencode.recordservice.provider.meterroom;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.manager.meterroom.MeterRoomRecordManager;
import cn.xopencode.recordservice.rpc.meterroom.MeterRoomRecordRpc;
import cn.xopencode.recordservice.rpc.meterroom.dto.MeterRoomRecordCreateDTO;
import cn.xopencode.recordservice.rpc.meterroom.dto.MeterRoomRecordPageDTO;
import cn.xopencode.recordservice.rpc.meterroom.dto.MeterRoomRecordUpdateDTO;
import cn.xopencode.recordservice.rpc.meterroom.vo.MeterRoomRecordAdminPageVO;
import cn.xopencode.recordservice.rpc.meterroom.vo.MeterRoomRecordPageVO;
import cn.xopencode.recordservice.rpc.meterroom.vo.MeterRoomRecordUpdateVO;
import cn.xopencode.recordservice.rpc.robotroom.dto.AdminRecordPageDTO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 仪表机柜间巡检记录 Rpc 实现类
 */
@DubboService(version = "${dubbo.provider.MeterRoomRecordRpc.version}")
public class MeterRoomRecordRpcImpl implements MeterRoomRecordRpc {

    @Autowired
    private MeterRoomRecordManager meterRoomRecordManager;
    /**
     * 新增仪表机柜间巡检记录
     *
     * @param createDTO
     * @return
     */
    @Override
    public CommonResult<Integer> createMeterRoomRecord(MeterRoomRecordCreateDTO createDTO) {
        return CommonResult.success(meterRoomRecordManager.createMeterRoomRecord(createDTO));
    }

    /**
     * 获得仪表机柜间巡检记录分页
     *
     * @param pageDTO
     * @return
     */
    @Override
    public CommonResult<PageResult<MeterRoomRecordPageVO>> pageRobotRoomRecord(MeterRoomRecordPageDTO pageDTO) {
        return CommonResult.success(meterRoomRecordManager.pageMeterRoomRecord(pageDTO));
    }

    /**
     * 根据记录id获取仪表机柜间巡检记录详情
     * @param id
     * @return
     */
    @Override
    public CommonResult<MeterRoomRecordUpdateVO> getMeterRoomRecordById(String id) {
        return CommonResult.success(meterRoomRecordManager.getMeterRoomRecordById(id));
    }

    /**
     * 更新仪表机柜间巡检记录
     * @param updateDTO
     * @return
     */
    @Override
    public CommonResult<Integer> updateMeterRoomRecord(MeterRoomRecordUpdateDTO updateDTO) {
        return CommonResult.success(meterRoomRecordManager.updateMeterRoomRecord(updateDTO));
    }

    /**
     * 处理 仪表机柜间巡检记录 中的异常，在巡检记录中只是改变状态
     * @param recordId
     * @return
     */
    @Override
    public CommonResult<Integer> dealMeterRoomRecordException(String recordId) {
        return CommonResult.success(meterRoomRecordManager.dealMeterRoomRecordException(recordId));
    }

    @Override
    public CommonResult<PageResult<MeterRoomRecordAdminPageVO>> getAdminPageMeterRoomRecord(AdminRecordPageDTO pageDTO) {
        return CommonResult.success(meterRoomRecordManager.getAdminPageMeterRoomRecord(pageDTO));
    }
}
